#include<iostream>
using namespace std;
//CDate类直接复制就好了
class CDate
{

    private:

        int year, month, day;

    public:

        CDate(int y, int m, int d);

        bool isLeapYear();

        int getYear();

        int getMonth();

        int getDay();

        int getDayofYear();

};

CDate::CDate(int y, int m, int d)
{ 

    year = y, month = m,day = d;

}

bool CDate::isLeapYear()
{ 

    return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; 

}

int CDate::getYear()

{ 

    return year;

}

int CDate::getMonth() 

{ 

    return month;

}

int CDate::getDay() 

{ 

    return day;

}

int CDate::getDayofYear()
{

    int i, sum = day;
    int a[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if (isLeapYear())
    {

        a[2]++;

    }
    // 求日期的天数

    for (i = 0; i < month; i++)

    {
        sum += a[i];

    }
    return sum;

}

class soft
{
    private:
        string name,type,media;
        char _type,_media;
        //两个标记type和media全英文的简写
        CDate date;
        //封闭类对象date，表示这个日期
    public:
        soft(string _name,char _t,char _m,int _y,int _o,int _d):name(_name),_type(_t),_media(_m),date(_y,_o,_d)
        {
            if(_type=='O')
                type="original";
            else if(_type=='B')
                type="backup";
            else
                type="trial";
            
            if(_media=='D')
                media="optical disk";
            else if(_media=='H')
                media="hard disk";
            else
                media="USB disk";
        }
        soft(const soft& a):date(a.date)
        {
            name=a.name;
            type="backup";
            media="hard disk";
            _type='B';
            _media='H';
        }
        void Print()
        {
            cout<<"name:"<<name<<endl;
            cout<<"type:"<<type<<endl;
            cout<<"media:"<<media<<endl;
            //先枚举各种过期的样例，在这里2015/4/7当日，是过期的
            if(date.getYear()==0)
            {
                cout<<"this software has unlimited use"<<endl;
                return;
            }
            if(date.getYear()<2015)
            {
                cout<<"this software has expired"<<endl;
            }
            else if(date.getYear()==2015 && date.getMonth()<4)
            {
                cout<<"this software has expired"<<endl;
            }
            else if(date.getYear()==2015 && date.getMonth()==4 && date.getDay()<=7)
            {
                cout<<"this software has expired"<<endl;
            }
            else
            {
                //然后在没过期里找剩余天数。
                //两个对象的getDayofYear()相加减，只能在同一年进行
                //所以，分成两种情况，一种是正好是2015年，一种是大于2015年
                int days=0;
                int year=date.getYear();
                if(year==2015)
                {
                    CDate ddl=CDate(2015,4,7);
                    days=date.getDayofYear()-ddl.getDayofYear();
                    //同一年直接调用函数
                }
                else
                {
                    days=date.getDayofYear();
                    year--;
                    while(year>2015)
                    {
                        CDate allyear(year,12,31);
                        days=days+allyear.getDayofYear();
                        year--;
                    }
                    CDate allyear(2015,12,31);
                    CDate ddl=CDate(2015,4,7);
                    days+=allyear.getDayofYear()-ddl.getDayofYear();
                }
                cout<<"this software is going to be expired in "<<days<<" days"<<endl;
            }
        }
};

int main()
{
    int t;
    cin>>t;
    int flag=1;
    while(t--)
    {
        string name;
        char _ty,_me;
        int y,m,d;
        cin>>name;
        cin>>_ty>>_me>>y>>m>>d;
        soft tmp(name,_ty,_me,y,m,d);
        if(!flag)
            cout<<endl;
        tmp.Print();
        cout<<endl;
        soft ans(tmp);
        ans.Print();
        flag=0;
    }
}